<template>
  <div class="container">
    <div class="home-statistics x-blue">
      <div>订单总数</div>
      <text>0</text>
    </div>
    <div class="home-statistics x-yellow">
      <div>收款金额</div>
      <text>0</text>
    </div>
    <div class="home-statistics x-red">
      <div>毛利率</div>
      <text>50%</text>
    </div>
    <div class="home-nav">
      <div class="home-nav-item" v-for="(item, index) in navList" :key="index">
        <img :src="item.img" alt="">
        <div>{{item.name}}</div>
      </div>
    </div>
  </div>
</template>
<script>
import STATE from '@/utils/state'
import API from '@/utils/api'

export default {
  data () {
    return {
      navList: [
        {
          id: 1,
          img: '/static/imgs/member.svg',
          name: '新增会员'
        },
        {
          id: 2,
          img: '/static/imgs/member2.svg',
          name: '会员管理'
        },
        {
          id: 3,
          img: '/static/imgs/goods-add.svg',
          name: '新增商品'
        },
        {
          id: 4,
          img: '/static/imgs/goods.svg',
          name: '商品管理'
        },
        {
          id: 5,
          img: '/static/imgs/report.svg',
          name: '经营概况'
        },
        {
          id: 6,
          img: '/static/imgs/supplier.svg',
          name: '供应商'
        },
        {
          id: 7,
          img: '/static/imgs/order.svg',
          name: '订单详细'
        },
        {
          id: 8,
          img: '/static/imgs/inventory.svg',
          name: '库存管理'
        },
        {
          id: 9,
          img: '/static/imgs/marketing.svg',
          name: '营销中心'
        },
        {
          id: 10,
          img: '/static/imgs/print.svg',
          name: '标签打印'
        },
        {
          id: 11,
          img: '/static/imgs/more.svg',
          name: '更多功能'
        }
      ]
    }
  },
  methods: {
    getShopList () {
      // let that = this
      let shopId = STATE.shopInfo.shopId
      wx.showLoading({
        title: '加载中...'
      })
      wx.request({
        url: `${API.ORDER.SALES}?shopId=${shopId}&type=2`,
        method: 'GET',
        header: {
          'content-type': 'application/json', // 默认值
          'cookie': wx.getStorageSync('SESSID')
        },
        success (res) {
          if (res.data.code === 0) {
            console.log(res)
            wx.hideLoading()
          }
        }
      })
    }
  },
  onLoad () {
    console.log(STATE)
    this.getShopList()
  }
}
</script>
<style scoped>
  .home-statistics {
    width: 90%;
    margin-top: 20rpx;
    border-radius: 8rpx;
    padding: 30rpx 10rpx;
    font-size: 32rpx;
    display: flex;
    align-items: center;
  }
  .home-statistics text {
    margin-left: 20rpx;
    font-size: 40rpx;
    flex: 1;
    text-align: right;
  }
  .home-nav {
    width: 100%;
    margin-top: 40rpx;
  }
  .home-nav-item {
    width: 25%;
    display: inline-block;
    font-size: 24rpx;
    text-align: center;
    margin-bottom: 40rpx;
  }
  .home-nav-item img {
    width: 60rpx;
    height: 60rpx;
    margin-bottom: 10rpx;
  }
</style>